package br.com.caelum.vraptor.util;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.Query;
import javax.persistence.TypedQuery;

import br.com.caelum.vraptor.entidades.Classe;
import br.com.caelum.vraptor.entidades.Diagrama;
import br.com.caelum.vraptor.entidades.Evento;
import br.com.caelum.vraptor.entidades.TipoEvento;

public class TesteConsultaEvento {

	public static void main(String[] args) {

		try {

			EntityManagerFactory emf = Persistence
					.createEntityManagerFactory("jpa-hibernate-mysql-dev-local");

			EntityManager em = emf.createEntityManager();
			
			Evento e = (Evento)em.find(Evento.class, 1);
			
			System.out.println("Evento: "+e.getNome());
			System.out.println("Tipo: "+e.getTipoEvento().getNome());
			
			em.close();
			emf.close();

			System.out.println("...");

		} catch (Exception e) {
			
			e.printStackTrace();
			System.out.println("Erro ..");

		}

	}

}
